<?php
include $this->Render('header.php');
?>
<link rel="stylesheet" type="text/css" href="<?php echo BASE_STYLE;?>/css/admin.css" />
<script type="text/javascript" src="<?php echo BASE_STYLE;?>/js/dyhl.linkpage.js"></script>
<script type="text/javascript" src="<?php echo BASE_STYLE;?>/js/common.js"></script>
<style type="text/css">
	.tongrong-box {
		padding:20px 30px 30px  30px;
	}
</style>
<div class="tongrong-box" style="width:650px;">
	<form class="login-box-form J-ajaxForm" action="<?php echo $this->id > 0 ? '/bank/update/option/save/' : '/bank/save/option/save/';?>" method="post" autocomplete="off">
	<div class="tongrong-box-main">
    	<table width="100%" cellpadding="0" cellspacing="0" border="0">
        	<tr>
            	<td width="90px" height="35">银行编号：</td>
                <td colspan="3">
                	<input name="bk_code" type="text" id="bk_code" size="35" value="<?php echo $this->data['bk_code'];?>" />
                </td>
            </tr>
            <tr>
            	<td height="35">银行名称：</td>
                <td colspan="3">
                	<input name="bk_name" type="text" id="bk_name" size="35" value="<?php echo $this->data['bk_name'];?>" />
                </td>
            </tr>
            <tr>
            	<td height="35">银行简称：</td>
                <td colspan="3">
                	<input name="bk_abbreviation" type="text" id="bk_abbreviation" size="35" value="<?php echo $this->data['bk_abbreviation'];?>" />
                </td>
            </tr>
            <tr>
            	<td colspan="2" style="padding:5px 0;">新车实际贷款比例上限(％)</td>
            </tr>
            <tr>
            	<td height="35">省内：</td>
                <td>
                	<input name="bk_newloan_in" type="text" id="bk_newloan_in" size="35" value="<?php echo $this->data['bk_newloan_in'];?>" />
                </td>
                <td height="35">省外：</td>
                <td>
                	<input name="bk_newloan_out" type="text" id="bk_newloan_out" size="35" value="<?php echo $this->data['bk_newloan_out'];?>" />
                </td>
            </tr>
            
            <tr>
            	<td colspan="2">二手车实际贷款比例上限(％)</td>
            </tr>
            <tr>
            	<td height="35">省内：</td>
                <td>
                	<input name="bk_secloan_in" type="text" id="bk_secloan_in" size="35" value="<?php echo $this->data['bk_secloan_in'];?>" />
                </td>
                <td height="35">省外：</td>
                <td>
                	<input name="bk_secloan_out" type="text" id="bk_secloan_out" size="35" value="<?php echo $this->data['bk_secloan_out'];?>" />
                </td>
            </tr>
            
            <tr>
            	<td colspan="2">新车申请分期付款总额比例(％)</td>
            </tr>
            <tr>
            	<td height="35">省内：</td>
                <td>
                	<input name="bk_newstage_in" type="text" id="bk_newstage_in" size="35" value="<?php echo $this->data['bk_newstage_in'];?>" />
                </td>
                <td height="35">省外：</td>
                <td>
                	<input name="bk_newstage_out" type="text" id="bk_newstage_out" size="35" value="<?php echo $this->data['bk_newstage_out'];?>" />
                </td>
            </tr>
            
            <tr>
            	<td colspan="2">二手车申请分期付款总额比例(％)</td>
            </tr>
            <tr>
            	<td height="35">省内：</td>
                <td>
                	<input name="bk_secstage_in" type="text" id="bk_secstage_in" size="35" value="<?php echo $this->data['bk_secstage_in'];?>" />
                </td>
                <td height="35">省外：</td>
                <td>
                	<input name="bk_secstage_out" type="text" id="bk_secstage_out" size="35" value="<?php echo $this->data['bk_secstage_out'];?>" />
                </td>
            </tr>
            <tr>
            	<td colspan="2">新车分期付款总额比例上限(％)</td>
            </tr>
            <tr>
            	<td height="35">省内：</td>
                <td>
                	<input name="bk_newratio_in" type="text" id="bk_newratio_in" size="35" value="<?php echo $this->data['bk_newratio_in'];?>" />
                </td>
                <td height="35">省外：</td>
                <td>
                	<input name="bk_newratio_out" type="text" id="bk_newratio_out" size="35" value="<?php echo $this->data['bk_newratio_out'];?>" />
                </td>
            </tr>
            <tr>
            	<td colspan="2">二手车分期付款总额比例上限(％)</td>
            </tr>
            <tr>
            	<td height="35">省内：</td>
                <td>
                	<input name="bk_secratio_in" type="text" id="bk_secratio_in" size="35" value="<?php echo $this->data['bk_secratio_in'];?>" />
                </td>
                <td height="35">省外：</td>
                <td>
                	<input name="bk_secratio_out" type="text" id="bk_secratio_out" size="35" value="<?php echo $this->data['bk_secratio_out'];?>" />
                </td>
            </tr>
            <tr><td colspan="4" height="5"></td></tr>
            <tr>
            	<td valign="top">银行范围：</td>
                <td colspan="3">
                	<style type="text/css">
						.bank-list {
							max-height:250px; overflow:auto; margin-top:5px; font-size:12px; border:1px solid #e1e1e1; padding:10px 15px; height:100px; overflow-y:scroll; overflow-x:hidden; width:390px;
						}
						
						.bank-list li {
							padding:3px 0;
						}
						
						.bank-list li input {
							vertical-align:sub;
						}
                    </style>
                    <p><input type="checkbox" class="checkAll" rel="bkinpro" value="1" /> 全选</p>
                    <ul class="bank-list J-bank-list">
                    	<li style="padding:10px;">加载中...</li>
                    </ul>
                    <script type="text/javascript">
                    	$(document).ready(function(e) {
                            $.post('/public/ajax/?option=city',function(data){
								<?php
									if(!empty($this->data['bk_inpro'])) {
										$len = count($this->data['bk_inpro']);
										foreach($this->data['bk_inpro'] as $key => $val){
											if($key == ($len - 1)){
												$txt .= '"'.$val.'"';
											}else{
												$txt .= '"'.$val.'",';
											}	
										}	
									}
								?>
								var selectArr = [<?php echo $txt !='' ? $txt : '';?>];
								if(data !=''){
									var html = '';
									for(var i in data){
										html+='<li>';
										html+='	<label>';
										
										if(selectArr.indexOf(data[i]["t"]) > -1){
											html+='	<input name="bk_inpro[]" type="checkbox" checked class="child_bkinpro" value="'+data[i]["t"]+'" />&nbsp; ';
										}else{
											html+='	<input name="bk_inpro[]" type="checkbox" class="child_bkinpro" value="'+data[i]["t"]+'" />&nbsp; ';
										}

										html+='	'+data[i]["t"]+'';
										html+='	</label>';
										html+='</li>';
									}
									
									$(".J-bank-list").html(html);	
								}	
							},'json');
                        });
                    </script>
                </td>
            </tr>
            
        </table>
    </div>
    <div class="luru-box-btn mt30" style="margin-right:80px;">
		<input type="hidden" name="option" value="save" />
		<input type="hidden" name="id" value="<?php echo $this->id;?>" />
    	<input class="btn-submit-blue fn-left mr15 J-submit" type="submit" value="提交" />
        <a class="a-btn-close J-a-btn-close" href="javascript:;">关闭</a>
    </div>
	</form>
</div>

<script>
	$("#areas").Linkage({ url:"/public/ajax/?option=city",selected:['<?php echo empty($this->data['br_province']) ? '浙江省' : $this->data['br_province'];?>','<?php echo empty($this->data['br_city']) ? '杭州市' : $this->data['br_city'];?>',''],callback:function(data){
		var text = new Array();
		var value = new Array();
		for(i in data[0]){
		  if(data[0][i]!=0){
			text.push(data[1][i]);
			value.push(data[0][i]);
		  }
		}
		$("#test").val(value.join(','));
		FireEvent(document.getElementById("test"),"change");
	}});
	
	//关闭弹出
	$(".J-a-btn-close").on('click',function(){
		
		var winElement = parent.Ext.fly(window.frameElement).up('div.x-window');
		parent.Ext.getCmp(winElement.id).close();
		
	});
	
	$(document).ready(function(e) {
        $(".J-submit").on('click',function(){
			$(this).dyhlForm({
				beforefunction:submitChk,
				nofunction:function(){
					$(".J-submit").prop('disabled',false);
				},
				sucessfunction:function(data){
					$(".J-submit").prop('disabled',false);
					if(data['success']){
						Ext.Msg.alert('提示','提交成功',function(){
							window.parent.App.store.reload();
							var winElement = parent.Ext.fly(window.frameElement).up('div.x-window');
							parent.Ext.getCmp(winElement.id).close();
						});
					}else{
						//alert(data['msg']);
						Ext.Msg.alert('提示',data['msg']);
					}
				}	
			});	
		});
    });
	
	//表单验证
	function submitChk(){
		if($("#bk_code").val() == ''){
			Ext.Msg.alert('提示','银行编号不能为空!');	
			return false;
		}
		
		if($("#bk_name").val() == ''){
			Ext.Msg.alert('提示','银行名称不能为空!');	
			return false;
		}
		
		if($("#bk_newloan_in").val() == ''){
			Ext.Msg.alert('提示','省内新车实际贷款比例上限不能为空!');	
			return false;
		}
		if($("#bk_newloan_out").val() == ''){
			Ext.Msg.alert('提示','省外新车实际贷款比例上限不能为空!');	
			return false;
		}
		
		if($("#bk_secloan_in").val() == ''){
			Ext.Msg.alert('提示','省内二手车实际贷款比例上限不能为空!');	
			return false;
		}
		if($("#bk_secloan_out").val() == ''){
			Ext.Msg.alert('提示','省外二手车实际贷款比例上限不能为空!');	
			return false;
		}
		
		if($("#bk_newstage_in").val() == ''){
			Ext.Msg.alert('提示','省内新车申请分期付款总额比例不能为空!');	
			return false;
		}
		if($("#bk_newstage_out").val() == ''){
			Ext.Msg.alert('提示','省外新车申请分期付款总额比例不能为空!');	
			return false;
		}
		
		if($("#bk_secstage_in").val() == ''){
			Ext.Msg.alert('提示','省内二手车申请分期付款总额比例不能为空!');	
			return false;
		}
		if($("#bk_secstage_out").val() == ''){
			Ext.Msg.alert('提示','省外二手车申请分期付款总额比例不能为空!');	
			return false;
		}
		
		if($("#bk_newratio_in").val() == ''){
			Ext.Msg.alert('提示','省内新车分期付款总额比例上限不能为空!');	
			return false;
		}
		if($("#bk_newratio_out").val() == ''){
			Ext.Msg.alert('提示','省外新车分期付款总额比例上限不能为空!');	
			return false;
		}
		
		if($("#bk_secratio_in").val() == ''){
			Ext.Msg.alert('提示','省内二手车分期付款总额比例上限不能为空!');	
			return false;
		}
		if($("#bk_secratio_out").val() == ''){
			Ext.Msg.alert('提示','省外二手车分期付款总额比例上限不能为空!');	
			return false;
		}
		
		$(".J-submit").prop('disabled',true);
			
	}
	
</script>

<?php include $this->Render('footer.php'); ?>